package org.example.JUC.waitTest.producerAndConsumer;

import org.example.JUC.Tools.MyBlockingQueue;

/**
 * @description:
 * @author: farprt
 * @create: 2022-08-20 19:51
 **/
public class Producer extends Thread{
    MyBlockingQueue<String> queue;
    public Producer(MyBlockingQueue<String> queue){
        this.queue=queue;
    }

    @Override
    public void run() {
        int num=0;
        while(true){
            try {
                String task=String.valueOf(num);
                queue.put(task);
                System.out.println("produce task"+task);
                num++;
                Thread.sleep((int) Math.random()*100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        }
    }
}